/**
 * 
 */
package imoney.client.handler;

import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.user.client.ui.TextBox;

/**
 * @author Arnaud PELOQUIN
 * Set the prefil content back if the field is still empty
 * after the focus leaves.
 */
public class BlurPrefilText implements BlurHandler {

	TextBox text;
	String content;
	
	public BlurPrefilText(TextBox textBox, String prefilContent) {
		text = textBox;
		content = prefilContent;
	}
	
	@Override
	public void onBlur(BlurEvent event) {
		if (text.getText().equals("")) {
			text.setText(content);
		}
		text.setVisibleLength(text.getText().length());
	}

}
